package database

import (
	"github.com/gin-contrib/sessions"
	"github.com/gin-contrib/sessions/cookie"
	"github.com/gin-gonic/gin"
)

func InitSession(r *gin.Engine) {
	store := cookie.NewStore([]byte("zhenjian")) // 基于cookie创建存储引擎, 设置密钥
	// session配置
	store.Options(sessions.Options{
		Secure:   true, // 针对https请求
		SameSite: 4,
		Path:     "/",
		MaxAge:   3600,
	})
	// 挂载session中间件
	r.Use(sessions.Sessions("mySession", store))
}
